package com.duan.common.configuration;


import com.duan.common.utils.redis.RedisLimit;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;

import java.util.HashSet;
import java.util.Set;

@Configuration
public class RedisLimitConfig {


    @Bean
    public RedisLimit redisLimit() {
        HostAndPort hostAndPort = new HostAndPort("172.16.30.2", 7000);
        HostAndPort hostAndPort1 = new HostAndPort("172.16.30.2", 7001);
        HostAndPort hostAndPort2 = new HostAndPort("172.16.30.2", 7002);
        HostAndPort hostAndPort3 = new HostAndPort("172.16.30.2", 7003);
        HostAndPort hostAndPort4 = new HostAndPort("172.16.30.2", 7004);
        HostAndPort hostAndPort5 = new HostAndPort("172.16.30.2", 7005);

        Set<HostAndPort> set = new HashSet<>();
        set.add(hostAndPort);
        set.add(hostAndPort1);
        set.add(hostAndPort2);
        set.add(hostAndPort3);
        set.add(hostAndPort4);
        set.add(hostAndPort5);

        JedisCluster jedisCluster = new JedisCluster(set);
        return new RedisLimit.Builder(jedisCluster).build();
    }
}
